

CCycNode::CCycNode(int cycNum, int restNum)
{
	this->type = Cycle;

	this->cycNum = cycNum;
	this->restNum = restNum;
	this->childList = new CNode();		/* First empty node */
	this->currentChild = childList;
	this->currentChild->nextNode = childList;
}


CCycNode::~CCycNode()
{
	while(childList != childList->nextNode)
	{
		CNode * delNode = childList->nextNode;

		childList->nextNode = delNode->nextNode;
		delete delNode;
	}
	delete childList;
}


void CCycNode::CalcYarn()
{
	CNode * node = childList;
	int value = 0;

	do
	{
		value += node->yarnNum;
		if(node->type == Color)
		{
			CColorNode * colorNode = (CColorNode*)node;
		}

		node = node->nextNode;
	}
	while(node != childList);
		
	this->singleNum = value;
	this->yarnNum = value * this->cycNum + this->restNum;
}


void CCycNode::AddNode(CNode * newNode)
{
	/* Prepare */
	newNode->parentNode = this;
	newNode->nextNode = this->childList;
	/* Insert to tail */
	this->currentChild->nextNode = newNode;
	this->currentChild = newNode;

	if(newNode->type == Color)
	{
		CColorNode * node = (CColorNode*)newNode;
	}
	else if(newNode->type == Cycle)
	{
		CCycNode * node = (CCycNode*)newNode;
	}
}


